<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>原生公众号应用示例-列表页</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
    <h1 class="page-header"><a href="javascript:;">原生公众号应用示例</a></h1>
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-warning">
                <div class="panel-heading">
                    <h2 class="text-center">新闻列表</h2>
                </div>
                <div class="panel-body">
                    <div class="list-group" style="margin-bottom: 50px;">
                        <a href="./menuone"><button type="button" class="btn btn-success pull-right" data-target="#exampleModal">新增</button></a>
                    </div>
                    <div class="list-group">
                        {% for news in list %}
                        <div class="" style="margin-bottom: 50px;">
                            <a href="./admindetail?id={{ news.id }}" class="list-group-item">
                                <h3>{{ news.title }}</h3>
                                <p>
                                    {{ news.description }}
                                </p>
                            </a>
                            <div class="pull-right">
                                <button type="button" class="btn btn-danger" onclick="deleteData({{ news.id }})">删除</button>
                                <a href="./menuone?id={{ news.id }}"><button type="button" class="btn btn-info" data-target="#exampleModal">编辑</button></a>
                            </div>
                        </div>
                        {% else %}
                        No news found.
                        {% endfor %}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function deleteData(id){
        var url = './delete';
        $.post(url, {id: id}, function(data) {
            if (0 == data.code) {
                alert(data.message)
                window.location.reload()
            }
        });
    }
</script>
</body>
</html>
